<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>系统级取色器</title>
</head>
<body>
    <button>取色</button>
    <label></label>
    <div class="box"></div>
</body>
<script>
    const btn = document.querySelector('button');
    const box = document.querySelector('.box');
    const label = document.querySelector('label');
    btn.onclick = async()=>{
        const dropper = new EyeDropper();
        try{
            const result = await dropper.open();
            console.log(result);
            box.style.backgroundColor = label.textContent=result.sRGBHex;
        }catch{
            console.log('use canceled');
        }
    }
</script>
</html>
